import http from "../../utility/request.js";
// import qs from 'qs'
const baseUrl = "http://47.109.157.141:8449/front"; // 轻松睡眠后台服务
// const baseUrl = process.env.NODE_ENV === "development" ? "https://tpost.relaverse.cn/qsxz/sleep" : "https://tpost.relaverse.cn/qsxz/sleep"; // 轻松睡眠后台服务

/**
 * 查询戒指
 * @returns {Promise<{status: string, msg: string, data: {id: number, mac: string, createTime: string | null}}> | *}
 */
export const queryUserRing = () =>
	http.get(`/rgUserRing/queryMyRing`, {
		baseUrl,
	});

/**
 * 解绑戒指
 * @returns {Promise<unknown> | *}
 */
export const unbindUserRing = () =>
	http.get(`/rgUserRing/unbindRgUserRing`, {
		baseUrl,
	});

/**
 * 绑定戒指
 * @param data {Object} 戒指的MAC地址
 * @param data.mac {string}
 * @param data.name {string}
 * @returns {Promise<unknown> | *}
 */
export const bindUserRing = (data) =>
	http.post(`/rgUserRing/bindRgUserRing`, {
		data,
		baseUrl,
	});

/**
 * 保存手机和戒指信息
 * @param {*} data
 * @returns
 */
export const saveDeviceInfo = (data) =>
	http.post(`/rgUserDevice/saveDeviceInfo`, {
		data,
		baseUrl,
	});

export const setRingMacAndName = (data) =>
	http.post(`/rgUserRing/setRgUserRing`, {
		data,
		baseUrl,
	});
